<?php
// +----------------------------------------------------------------------
// | Publics.
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.suckseed.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: wjf <184521508@qq.com> 2017-07-08
// +----------------------------------------------------------------------

namespace app\user\controller;

use wjf\controller\HomeBase;
use app\user\model\User;
use think\Validate;

class Publics extends HomeBase
{
    // 用户头像api
    public function avatar()
    {
        $id   = $this->request->param("id", 0, "intval");
        $user = User::get($id);

        $avatar = '';
        if (!empty($user)) {
            $avatar = wjf_get_user_avatar_url($user['avatar']);
        }

        if (empty($avatar)) {
            $avatar = wjf_get_root() . "/static/images/headicon.png";
        }

        return $this->redirect($avatar);
    }
}